//
//  GuideScene.m
//  GameProject
//
//  Created by Blair Trusler on 20/02/2012.
//  Copyright (c) 2012 Blair Trusler. All rights reserved.
//

#import "GameHeader.h"

@implementation GuideScene
#pragma mark - scene
+(id) scene
{
    CCScene *scene = [CCScene node];
    
    GuideScene *layer = [GuideScene node];
    
    [scene addChild: layer];
    
    return scene;
}


#pragma mark - initialize
-(id) init
{
    if( (self=[super init] )) {
        CCLOG(@"Loading Guide...");
        
        [self loadScreenContents];
        
        CCLOG(@"Guide loaded.");
    }
    return self;
}


-(void)loadScreenContents{
    CGSize winSize = [CCDirector sharedDirector].winSize;
    
    CCSprite *guideTitle = [CCSprite spriteWithFile:@"Guide.png"];
    CCSprite *objectiveTitle = [CCSprite spriteWithFile:@"Objective.png"];
    CCSprite *charactersTitle = [CCSprite spriteWithFile:@"Characters.png"];

    CCSprite *objectiveFull = [CCSprite spriteWithFile:@"ObjectiveFull.png"];
    CCSprite *charactersFull = [CCSprite spriteWithFile:@"CharacterDescriptions.png"];
    
    CCSprite *playerSprite = [CCSprite spriteWithFile:@"RPG_Sprite_Single.png"];
    CCSprite *minotaurSprite = [CCSprite spriteWithFile:@"E2Down2.png"];
    CCSprite *enemyGuardSprite = [CCSprite spriteWithFile:@"E1Down1.png"];

    
    CCMenuItemImage *returnToTitleScreen = [CCMenuItemImage itemFromNormalImage:@"backbutton.png" selectedImage:@"backbutton.png" target:self selector:@selector(returnToTitleScreen:)];
    CCMenu *returnToTitleScreenMenu = [CCMenu menuWithItems:returnToTitleScreen, nil];
    
    
    if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad){
        returnToTitleScreen.scale = 0.6f;
        returnToTitleScreenMenu.position = ccp(50 , 720);
        
        guideTitle.position = ccp(winSize.width/2, 700);
        objectiveTitle.position = ccp(200,600);
        objectiveFull.position = ccp(500,450);
        
        charactersTitle.position = ccp(200,300);
        charactersFull.position = ccp(500,175);
        
        playerSprite.scale = 1.5f;
        minotaurSprite.scale = 1.5f;
        enemyGuardSprite.scale = 1.5f;
        playerSprite.position = ccp(300,225);
        minotaurSprite.position = ccp(300,175);
        enemyGuardSprite.position = ccp(300,125);
    }
    else{
        
//        returnToTitleScreenMenu.position = ccp(-20,winSize.height*0.78);
        returnToTitleScreen.scale = 0.4f;
        returnToTitleScreenMenu.position = ccp(26,winSize.height*0.9);

        guideTitle.scale = 0.75f;
        guideTitle.position = ccp(winSize.width/2, winSize.height*0.85);
        objectiveTitle.scale = 0.5f;
        objectiveTitle.position = ccp(winSize.width*0.20, winSize.height*0.78);
        objectiveFull.scale = 0.5f;
        objectiveFull.position = ccp(winSize.width*0.50,winSize.height*0.55);
        
        charactersTitle.scale = 0.5f;
        charactersTitle.position = ccp(winSize.width*0.20, winSize.height*0.32);
        charactersFull.scale = 0.5f;
        charactersFull.position = ccp(winSize.width*0.60, winSize.height*0.2);
        
        
        playerSprite.scale = 0.75f;
        minotaurSprite.scale = 0.75f;
        enemyGuardSprite.scale = 0.75f;
        playerSprite.position = ccp(winSize.width*0.4,winSize.height*0.3);
        minotaurSprite.position = ccp(winSize.width*0.4,winSize.height*0.2);
        enemyGuardSprite.position = ccp(winSize.width*0.4,winSize.height*0.1);

        
    }
    [self addChild:guideTitle];
    [self addChild:objectiveTitle];
    [self addChild:objectiveFull];
    [self addChild:charactersTitle];
    [self addChild:charactersFull];
    [self addChild:playerSprite];
    [self addChild:minotaurSprite];
    [self addChild:enemyGuardSprite];
    [self addChild:returnToTitleScreenMenu];
}


-(void)returnToTitleScreen:(id)sender{
    
    [AudioManager playMenuButtonClick];
    [[CCDirector sharedDirector] popScene]; //'pops' back to previous scene    

//    [AudioManager playMenuButtonClick];
//    [[SceneManager sharedSceneManager] runSceneWithID:kMainMenuScene];    
}

@end

